﻿<%@ Page Language="C#" MasterPageFile="~/Hero.master" Title="Untitled Page" %>

<script runat="server">

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h1 class="mainTitle">Add comment to this song</h1>
	<asp:DetailsView ID="dvComment" runat="server" AutoGenerateRows="False" 
		DataKeyNames="ID" DataSourceID="sdsComment" DefaultMode="Insert">
		<Fields>
			<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
				ReadOnly="True" SortExpression="ID" />
			<asp:BoundField DataField="SongID" HeaderText="SongID" InsertVisible="False" 
				SortExpression="SongID" />
			<asp:BoundField DataField="UserName" HeaderText="UserName" 
				SortExpression="UserName" />
			<asp:TemplateField HeaderText="Message" SortExpression="Message">
				<EditItemTemplate>
					<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Message") %>'></asp:TextBox>
				</EditItemTemplate>
				<InsertItemTemplate>
					<asp:TextBox ID="txtMessage" runat="server" Rows="5" 
						Text='<%# Bind("Message") %>' TextMode="MultiLine"></asp:TextBox>
				</InsertItemTemplate>
				<ItemTemplate>
					<asp:Label ID="Label1" runat="server" Text='<%# Bind("Message") %>'></asp:Label>
				</ItemTemplate>
			</asp:TemplateField>
			<asp:CommandField ShowCancelButton="False" ShowInsertButton="True" />
		</Fields>
	</asp:DetailsView>
	<asp:SqlDataSource ID="sdsComment" runat="server" 
		ConflictDetection="CompareAllValues" 
		ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString %>" 
		DeleteCommand="DELETE FROM [Comments] WHERE [ID] = @original_ID AND [SongID] = @original_SongID AND [UserName] = @original_UserName AND [Message] = @original_Message AND [CreatedDate] = @original_CreatedDate" 
		InsertCommand="INSERT INTO [Comments] ([SongID], [UserName], [Message]) VALUES (@SongID, @UserName, @Message)" 
		OldValuesParameterFormatString="original_{0}" 
		SelectCommand="SELECT * FROM [Comments] WHERE ([SongID] = @SongID)" 
		UpdateCommand="UPDATE [Comments] SET [SongID] = @SongID, [UserName] = @UserName, [Message] = @Message, [CreatedDate] = @CreatedDate WHERE [ID] = @original_ID AND [SongID] = @original_SongID AND [UserName] = @original_UserName AND [Message] = @original_Message AND [CreatedDate] = @original_CreatedDate">
		<SelectParameters>
			<asp:QueryStringParameter Name="SongID" QueryStringField="SongID" 
				Type="Int32" />
		</SelectParameters>
		<DeleteParameters>
			<asp:Parameter Name="original_ID" Type="Int32" />
			<asp:Parameter Name="original_SongID" Type="Int32" />
			<asp:Parameter Name="original_UserName" Type="String" />
			<asp:Parameter Name="original_Message" Type="String" />
			<asp:Parameter Name="original_CreatedDate" Type="DateTime" />
		</DeleteParameters>
		<UpdateParameters>
			<asp:Parameter Name="SongID" Type="Int32" />
			<asp:Parameter Name="UserName" Type="String" />
			<asp:Parameter Name="Message" Type="String" />
			<asp:Parameter Name="CreatedDate" Type="DateTime" />
			<asp:Parameter Name="original_ID" Type="Int32" />
			<asp:Parameter Name="original_SongID" Type="Int32" />
			<asp:Parameter Name="original_UserName" Type="String" />
			<asp:Parameter Name="original_Message" Type="String" />
			<asp:Parameter Name="original_CreatedDate" Type="DateTime" />
		</UpdateParameters>
		<InsertParameters>
			<asp:QueryStringParameter Name="SongID" QueryStringField="SongID" 
				Type="Int32" />
			<asp:Parameter Name="UserName" Type="String" />
			<asp:Parameter Name="Message" Type="String" />
		</InsertParameters>
	</asp:SqlDataSource>
</asp:Content>

